package com.ithanwen.service.Impl;

import com.ithanwen.mapper.ClazzMapper;
import com.ithanwen.mapper.EmpMapper;
import com.ithanwen.mapper.StudentMapper;
import com.ithanwen.pojo.Clazz;
import com.ithanwen.pojo.ClazzCountOption;
import com.ithanwen.pojo.JobOption;
import com.ithanwen.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Created By tony
 * <br/>Date: 2025/7/14 14:41
 * <br/>Description:
 */
@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private ClazzMapper clazzMapper;
    @Override
    public JobOption getEmpJobData() {
        List<Map<String,Object>> list = empMapper.countEmpJobOption();
        List<String> joblist = list.stream().map(m -> m.get("pos").toString()).collect(Collectors.toList());
        List<Integer> datalist = list.stream().map(m -> Integer.parseInt(m.get("num").toString())).collect(Collectors.toList());
        return new JobOption(joblist,datalist);
    }

    @Override
    public List<Map<String, Integer>> getGenderData() {
        List<Map<String,Integer>> list = empMapper.countEmpGenderOption();
        return list;
    }

    @Override
    public List<Map<String, Integer>> getStudentDegreeData() {
        List<Map<String,Integer>> list = studentMapper.countStudentDegreeOption();
        return list;
    }

    @Override
    public ClazzCountOption getClazzCountOption() {
        List<Map<String,Object>> list = clazzMapper.countClazzOption();
        List clazzList = list.stream().map(map -> map.get("name").toString()).collect(Collectors.toList());
        List dataList = list.stream().map(map -> map.get("value")).collect(Collectors.toList());
        return new ClazzCountOption(clazzList,dataList);
    }
}
